package com.software.chemistry.controller;
import com.software.chemistry.entity.StudentInfo;
import com.software.chemistry.entity.TeacherInfo;
import com.software.chemistry.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    //根据id查询用户信息
    @GetMapping("/findTeacherInfoByUserId/{userId}")
    public TeacherInfo findTeacherInfoByUserId(@PathVariable String userId){
        TeacherInfo teacherInfo = teacherService.findTeacherInfoByUserId(userId) ;
        return teacherInfo;
    }

    //查询用户信息
    @GetMapping("/findTeacherInfoByUserId")
    public TeacherInfo findTeacherInfo(@PathVariable String userId){
        TeacherInfo teacherInfo = teacherService.findTeacherInfoByUserId(userId) ;
        return teacherInfo;
    }

    //修改个人信息
    @PostMapping("/updateTeacherInfo")
    public TeacherInfo updateTeacherInfo(TeacherInfo teacherInfo){
        String userId = teacherInfo.getUserId();
        TeacherInfo teacherInfo1 = findTeacherInfoByUserId(userId);
        String password = teacherInfo1.getPassword();
        teacherInfo.setPassword(password);

        TeacherInfo update = teacherService.updateTeacherInfo(teacherInfo);
        return update;
    }

}
